package com.zjj.fanshe.proxy.dongtai;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date
 */
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class LogInvocationHandler implements InvocationHandler {
    private Object target;

    public LogInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("日志: the method " + method.getName() + " begin with");
        for (Object arg : args) {
            System.out.print(arg + " ");
        }
        System.out.println();
        Object result = method.invoke(target, args);
        System.out.println("日志: the method " + method.getName() + " end with " + result);
        return result;
    }
}